﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var auditData = Jxstar.findComboData('audit');
	var baotypeData = Jxstar.findComboData('baotype');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var projectjdData = Jxstar.findComboData('projectjd');
	var yesnoData = Jxstar.findComboData('yesno');
	var plantype2Data = Jxstar.findComboData('plantype2');
	var planyearData = Jxstar.findComboData('planyear');
	var planstatusData = Jxstar.findComboData('planstatus');
	var plantypeData = Jxstar.findComboData('plantype');

	var cols = [
	{col:{header:'记录状态', width:68, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'money_plan__audit_up',type:'string'}},
	{col:{header:'计划包属性', width:86, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < baotypeData.length; i++) {
				if (baotypeData[i][0] == value)
					return baotypeData[i][1];
			}
		}}, field:{name:'money_plan__bao_type',type:'string'}},
	{col:{header:'项目名称', width:146, sortable:true}, field:{name:'money_plan__plan_name',type:'string'}},
	{col:{header:'建设规模和建设内容', width:263, sortable:true, hidden:true}, field:{name:'money_plan__plan_desc',type:'string'}},
	{col:{header:'项目类别', width:87, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'money_plan__money_type',type:'string'}},
	{col:{header:'项目状态', width:74, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: projectjdData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: projectjdData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < projectjdData.length; i++) {
				if (projectjdData[i][0] == value)
					return projectjdData[i][1];
			}
		}}, field:{name:'money_plan__plan_status2',type:'string'}},
	{col:{header:'*预计总投资(万元)', width:121, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_money',type:'float'}},
	{col:{header:'*本年度计划投资(万元)', width:152, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money',type:'float'}},
	{col:{header:'当前形象进度', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: projectjdData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: projectjdData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < projectjdData.length; i++) {
				if (projectjdData[i][0] == value)
					return projectjdData[i][1];
			}
		}}, field:{name:'money_plan__project_process',type:'string'}},
	{col:{header:'年度项目实施内容', width:152, sortable:true, hidden:true}, field:{name:'money_plan__year_content2',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_id',type:'string'}},
	{col:{header:'申报部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__dept_id',type:'string'}},
	{col:{header:'是否上报国家局', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__up_comp',type:'string'}},
	{col:{header:'国家局项目类别', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < plantype2Data.length; i++) {
				if (plantype2Data[i][0] == value)
					return plantype2Data[i][1];
			}
		}}, field:{name:'money_plan__money_type2',type:'string'}},
	{col:{header:'预算年度', width:64, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planyearData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planyearData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planyearData.length; i++) {
				if (planyearData[i][0] == value)
					return planyearData[i][1];
			}
		}}, field:{name:'money_plan__plan_year',type:'string'}},
	{col:{header:'申报单位', width:100, sortable:true}, field:{name:'money_plan__dept_name',type:'string'}},
	{col:{header:'计划编号', width:107, sortable:true}, field:{name:'money_plan__plan_code',type:'string'}},
	{col:{header:'计划状态', width:83, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatusData.length; i++) {
				if (planstatusData[i][0] == value)
					return planstatusData[i][1];
			}
		}}, field:{name:'money_plan__plan_status',type:'string'}},
	{col:{header:'项目id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__project_id',type:'string'}},
	{col:{header:'计划类型', width:100, sortable:true, hidden:true, align:'center',
		renderer:function(value){
			for (var i = 0; i < plantypeData.length; i++) {
				if (plantypeData[i][0] == value)
					return plantypeData[i][1];
			}
		}}, field:{name:'money_plan__plan_type',type:'string'}},
	{col:{header:'申请人', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_user',type:'string'}},
	{col:{header:'申请日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__plan_date',type:'date'}},
	{col:{header:'申报人ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_userid',type:'string'}},
	{col:{header:'父计划ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_parentid',type:'string'}},
	{col:{header:'计划批复金额(万元)', width:147, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__check_money',type:'float'}},
	{col:{header:'立项批复金额(万元)', width:143, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__project_money',type:'float'}},
	{col:{header:'合同金额(万元)', width:100, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__money_contract',type:'float'}},
	{col:{header:'已付款金额(万元)', width:100, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__money_pay',type:'float'}},
	{col:{header:'竣工决算审计金额(万元)', width:140, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__cost_money',type:'float'}},
	{col:{header:'上报金额(万元)', width:100, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__app_money',type:'float'}},
	{col:{header:'调概后批复金额(万元)', width:133, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__check_moneychk',type:'float'}},
	{col:{header:'国家局批复金额(万元)', width:159, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__check_money2',type:'float'}},
	{col:{header:'国家局批复年度投资(万元)', width:181, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__year_money2',type:'float'}},
	{col:{header:'截止上年底累计付款(万元)', width:169, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__sun_money1',type:'float'}},
	{col:{header:'今年截止统计月份累计付款(万元)', width:195, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__tran_money1',type:'float'}},
	{col:{header:'今年剩余月份预计付款(万元)', width:178, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:2, maxLength:12
		}),renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__tran_money2',type:'float'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'money_modify_sub'
	};
	
	config.eventcfg = {		
			delsub: function(){
				var records = this.grid.getSelectionModel().getSelections();
				if (!JxUtil.selected(records)) return;
				
				var self = this;
				//取选择记录的主键值
				var params = 'funid='+ self.define.nodeid;
				for (var i = 0; i < records.length; i++) {
					params += '&keyid=' + records[i].get(self.define.pkcol);
				}

				//设置请求的参数
				params += '&pagetype=subeditgrid&eventcode=delsub';

				//执行处理的内容
				var endcall = function(data) {
					//重新加载数据
					self.grid.getStore().reload();
				};

				//发送请求
				Request.postRequest(params, endcall);
			}
		};

	config.initpage = function(gridNode) {
		var grid = gridNode.page;
		
		//子表关闭时汇总统计主记录金额，并刷新
		grid.on('beforedestroy', function(g){
			//取选择记录的主键值
			var params = 'funid=money_modify_sub';
			var parentId = g.tmpParentId;
			var parentFunId = g.tmpParentFunId;
			if (!parentFunId) return;
			
			//设置请求的参数
			params += '&pagetype=subeditgrid&eventcode=statmoney&parentid=' + parentId;
			
			//执行处理的内容
			var endcall = function(data) {
				var pgrid = Ext.getCmp('node_' + parentFunId + '_editgrid');
				//重新加载数据
				if (pgrid) pgrid.getStore().reload();
			};

			//发送请求
			Request.postRequest(params, endcall);
		});
	};
		
	return new Jxstar.GridNode(config);
}